/**
 * Created by Administrator on 15-10-12.
 */
window.onload=function(){
    var id=$.getUrlParam("id");
    var url = getUrl();
    var userid=getUserId();
    $.jsonp({
        url: 'http://'+url+'/api/user/user_address_list',
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            $.each(data.arrays, function (index, ele) {
                var html = '<li class="ui-border-t">' +
                    '<label class="ui-checkbox-s">' +
                    '<input type="radio" data-id="'+ele.id+'" name="checkbox" checked>' +
                    '</label>' +
                    '<div class="pl10">'+ele.realName+''+ele.telphone+'<br/>'+ele.address+'</div>' +
                    '</li>';
                $("#dizhi").append(html)
            })
        },

        error: function (xOptions, textStatus) {
        }
    });

    $(".log-dzsc").on("click",function(){

        var id=$("input:checked").data('id');
        $.jsonp({
            url: 'http://'+url+'/api/user/delete_address-'+id,
            data: {userAddressId:id,userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                location.reload()
            },
            error: function (xOptions,textStatus) {
            }
        });
    });


}
